package com.hitsz.cdq;

import android.app.Fragment;
import android.app.FragmentManager;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

/**
 * Created by ChenDongqiang on 2017/2/18.
 */
public class SimulateTestFragment extends Fragment {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    private Button btn_task_admin,btn_task_release;
    private TextView tv_task_admin,tv_task_release;
    private FragmentManager fm;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.content_simulate_test, container, false);

        btn_task_admin= (Button) view.findViewById(R.id.btn_task_admin);
        btn_task_release= (Button) view.findViewById(R.id.btn_task_release);
        tv_task_admin= (TextView) view.findViewById(R.id.tv_task_admin);
        tv_task_release= (TextView) view.findViewById(R.id.tv_task_release);

        fm = getFragmentManager();
        Fragment fg = new TaskAdminFragment();
        fm.beginTransaction().replace(R.id.content_simulate_frame_layout, fg).commit();
        btn_task_admin.setEnabled(false);
        btn_task_admin.setTextColor(Color.WHITE);
        tv_task_admin.setVisibility(View.VISIBLE);
        btn_task_release.setEnabled(true);
        btn_task_release.setTextColor(Color.LTGRAY);
        tv_task_release.setVisibility(View.INVISIBLE);

        btn_task_admin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                btn_task_admin.setEnabled(false);
                btn_task_admin.setTextColor(Color.WHITE);
                tv_task_admin.setVisibility(View.VISIBLE);

                Fragment fg = new TaskAdminFragment();
                fm.beginTransaction().replace(R.id.content_simulate_frame_layout, fg).commit();

                btn_task_release.setEnabled(true);
                btn_task_release.setTextColor(Color.LTGRAY);
                tv_task_release.setVisibility(View.INVISIBLE);

            }
        });

        btn_task_release.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                btn_task_release.setEnabled(false);
                btn_task_release.setTextColor(Color.WHITE);
                tv_task_release.setVisibility(View.VISIBLE);

                Fragment fg = new TaskReleaseFragment();
                fm.beginTransaction().replace(R.id.content_simulate_frame_layout, fg).commit();

                btn_task_admin.setEnabled(true);
                btn_task_admin.setTextColor(Color.LTGRAY);
                tv_task_admin.setVisibility(View.INVISIBLE);

            }
        });

        return view;
    }


}
